package cn.iocoder.boot.enums;

import java.util.Objects;

public enum SupplierCodeEnum {

    JBCHIP("VEND0001", "京北通宇商城"),

    ICEAZY("VEND0002", "艾矽易"),
    TME("VEND0003", "TME"),
    MOUSER("VEND0004", "昴氏电子元器件"),
    DIGIKEY("VEND0005", "得捷电子"),
    ELEMENT("VEND0006", "易洛盟"),
    IC("VEND0007", "云汉"),
    SHT("VEND0008", "圣禾堂"),
    ;

    private final String code; // code 字段
    private final String name; // name 字段

    // 构造函数，传入 code 和 name 参数
    SupplierCodeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    // 获取 code 的方法
    public String getCode() {
        return code;
    }

    // 获取 name 的方法
    public String getName() {
        return name;
    }

    // 通过 code 获取对应的枚举
    public static SupplierCodeEnum fromCode(String code) {
        for (SupplierCodeEnum supplier : SupplierCodeEnum.values()) {
            if (Objects.equals(supplier.getCode(), code)) {
                return supplier;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
}

